package 华为OD机试B卷复用题.基础题;

import utils.MyUtil;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class HJ43_分糖果 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试B卷复用题/基础题/input/43.txt"));
        MyUtil.START();
        Solution(in);
        MyUtil.END();
    }

    static void Solution(Scanner in) {
        System.out.println(dfs(27));
    }

    static int dfs(int tangguo) {
        if (tangguo == 1) {
            return 0;
        }
        if (tangguo % 2 == 0) {
            return dfs(tangguo / 2) + 1;
        }
        return Math.min(dfs((tangguo - 1) / 2), dfs((tangguo + 1) / 2)) + 2;
    }
}
